<template>
  <div class="app-container">
    <div class="filter-container">
      <el-input
        v-model="listQuery.author"
        placeholder="请输入作者"
        style="width: 200px;"
        class="filter-item"
      />
      <!-- <el-select
        v-model="listQuery.status"
        placeholder="请选择状态"
        clearable
        style="width: 90px"
        class="filter-item"
      >
        <el-option
          v-for="item in selectOptions"
          :key="item.key"
          :label="item.label"
          :value="item.key"
        />
      </el-select> -->
      <el-button
        v-waves
        class="filter-item"
        type="primary"
        icon="el-icon-search"
        @click="handleFilter"
      >查询</el-button>
      <el-button
        v-waves
        class="filter-item"
        type="info"
        icon="el-icon-refresh"
        @click="handleReset"
      >重置</el-button>
    </div>
    <el-table
      v-loading="listLoading"
      :data="list"
      border
      fit
      highlight-current-row
      style="width: 100%;"
      height="300px"
      @row-click="rowClick"
    >
      <el-table-column label="ID" prop="id" align="center" width="200px">
        <template slot-scope="scope">
          <span>{{ scope.row.id }}</span>
        </template>
      </el-table-column>
      <el-table-column label="Date" width="200px" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.timestamp | parseTime('{y}-{m}-{d} {h}:{i}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="Author" width="200px" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.author }}</span>
        </template>
      </el-table-column>
      <el-table-column label="Status" class-name="status-col" width="200px">
        <template slot-scope="scope">
          <span>{{ scope.row.status }}</span>
          <!-- <el-tag :type="scope.row.status | statusTypeFilter">{{ scope.row.status | statusFilter }}</el-tag> -->
        </template>
      </el-table-column>
    </el-table>
    <pagination style="margin-top:10px;" v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="getList"/>
    <el-tabs v-model="activeName" type="card">
      <el-tab-pane label="用户管理" name="first">用户管理</el-tab-pane>
      <el-tab-pane label="配置管理" name="second">配置管理</el-tab-pane>
      <el-tab-pane label="角色管理" name="third">角色管理</el-tab-pane>
      <el-tab-pane label="定时任务补偿" name="fourth">定时任务补偿</el-tab-pane>
    </el-tabs>
  </div>
</template>
<style scoped>

</style>
<script>
import {
  fetchList,
  createData,
  updateData,
  deleteById
} from "@/api/bdc/manual-operate";
import waves from "@/directive/waves"; // waves directive
import { parseTime } from "@/utils";
import Pagination from "@/components/Pagination"; 
export default {
  name: 'OneCarOneGear',
  directives: { waves },
  components: { Pagination },
  data() {
    return {
      // 查询模块
      listQuery: {
        page: 1,
        limit: 10,
        author: undefined,
      },
      // 表格显示
      tableKey: 0,
      list: null,
      // test
      total: 1,
      listLoading: false,
      // tabs页
      activeName: 'first'
    }
  },
  created() {
    this.getList()
  },
  methods: {
    getList() {
      this.listLoading = false
      this.list = [
        { id: 1, timestamp: new Date().valueOf(), author: 'aaa'},
        { id: 1, timestamp: new Date().valueOf(), author: 'aaa'},
        { id: 1, timestamp: new Date().valueOf(), author: 'aaa'},
        { id: 1, timestamp: new Date().valueOf(), author: 'aaa'},
        { id: 1, timestamp: new Date().valueOf(), author: 'aaa'},
        { id: 1, timestamp: new Date().valueOf(), author: 'aaa'},
        { id: 1, timestamp: new Date().valueOf(), author: 'aaa'},
        { id: 1, timestamp: new Date().valueOf(), author: 'aaa'},
        { id: 1, timestamp: new Date().valueOf(), author: 'aaa'},
        { id: 1, timestamp: new Date().valueOf(), author: 'aaa'}
      ]
      // fetchList(this.listQuery).then(res => {
      //   if (res.code == 200) {
      //     this.list = res.data.list
      //     this.total = res.data.total
      //   } else {
      //     this.$message.error('服务器内部错误！');
      //   }
      //   this.listLoading = false
      // })
    },
    // 查询
    handleFilter() {
      this.listQuery.page = 1
      this.getList()
    },
    // 重置
    handleReset() {
      this.listQuery = {
        page: 1,
        limit: 10,
        author: undefined,
      }
    },
    // 行点击
    rowClick(row) {
      console.log(row)
      this.activeName = 'second'
    }
  }
}
</script>